#!/usr/bin/env node

const http = require('http');

const addr = 'http://www.baidu.com';

http.get(addr, (res)=>{
  console.log(`HTTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  console.log(res.headers);
  console.log();
  res.pipe(process.stdout);

  let data = '';
  res.on('data', (chunk)=>{
    data += chunk;
  });

  res.on('end', ()=>{
    console.log(JSON.parse(data));
    for(const rep)
  }); 
});
